package org.opengauss.evaluate.paeser.sqlparser.fileinput;

import com.github.javaparser.JavaParser;
import com.github.javaparser.ParseResult;
import com.github.javaparser.ast.CompilationUnit;
import org.objectweb.asm.*;
import org.opengauss.evaluate.common.exception.ServiceException;
import org.opengauss.evaluate.paeser.sqlparser.SqlParser;
import org.opengauss.evaluate.visitor.ClassAnnotationVisitor;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.SQLException;

/**
 * @author biao.yang
 * @Description:
 * @date 2025/3/24 16:55
 */
public class ClassSqlParser implements SqlParser {

    public static void main(String[] args) throws IOException {
        try{
            Path startDir = Paths.get("E:\\Personal\\mumufei\\yiling\\yl-server-v2");
            Files.walk(startDir).filter(Files::isRegularFile)
                    .forEach(path -> {
                        String fileName = path.toString();
                        if (fileName.endsWith(".class")) {
                            try {
                                byte[] classBytes = Files.readAllBytes(path);
                                ClassReader reader = new ClassReader(classBytes);
                                reader.accept(new ClassAnnotationVisitor(), 0);

                            } catch (IOException e) {
                                throw new RuntimeException(e);
                            }
                        }
                    });
        }catch (Exception e) {
            throw new ServiceException("Read path file fail.");
        }
    }

    @Override
    public void parseSql() throws IOException, SQLException {

    }
}


